package com.zjj.bams.entity;

import com.zjj.bams.exception.BalanceNotEnoughException;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 */
public class SavingAccount extends Account{

    public SavingAccount() {
    }

    public SavingAccount(String password, String name, String personId, String email, double balance) {
        super(password, name, personId, email, balance);
    }

    public SavingAccount(Long id, String password, String name, String personId, String email, double balance) {
        super(id, password, name, personId, email, balance);
    }

    @Override
    public Account withdraw(double money) throws BalanceNotEnoughException {
        if(this.getBalance()<money){
            /*System.out.println("您的银行卡余额不足");
            return this;*/
            throw new BalanceNotEnoughException("您的银行卡余额不足");
        }
        this.setBalance(this.getBalance() - money);
        return this;
    }

    @Override
    public String toString() {
        return "SavingAccount{} " + super.toString();
    }
}
